package com.zhou.common.operator.log.core.util;


import com.zhou.common.operator.log.core.annotation.OperateLog;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;

public class JoinPointHelper {

    public static Object[] getJoinPointArgs(ProceedingJoinPoint joinPoint) {
        return joinPoint.getArgs();
    }

    public static OperateLog getOperateLog(ProceedingJoinPoint joinPoint) {
        Method method = getJoinPointMethod(joinPoint);
        OperateLog operateLog = method.getAnnotation(OperateLog.class);
        return operateLog;
    }

    public static Method getJoinPointMethod(ProceedingJoinPoint joinPoint) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        return signature.getMethod();
    }

    public static String getMethodName(ProceedingJoinPoint joinPoint) {
        return getJoinPointMethod(joinPoint).getName();
    }
}
